/*
 * @Author: csh
 * @Date: 2022-07-27
 * @LastEditors: csh
 * @LastEditTime: 2022-10-13
 * @Description: file content
 * @FilePath: /wochat-vue3-ts-pinia/src/router/index.ts
 */
import { createRouter, createWebHashHistory, createWebHistory, RouteRecordRaw } from 'vue-router';

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Index',
    meta: {
      title: '首页',
      keepAlive: true,
      requireAuth: true
    },
    component: () => import('@/views/home.vue')
  },
  {
    path: '/login',
    name: 'Login',
    meta: {
      title: '登录',
      keepAlive: true,
      requireAuth: true
    },
    component: () => import('@/views/login.vue')
  },
  {
    path: '/test',
    name: 'Test',
    meta: {
      title: '测试',
      keepAlive: true,
      requireAuth: true
    },
    component: () => import('@/views/test/test.vue')
  },
  {
    path: '/webrtc/stream',
    name: 'WebRTC',
    meta: {
      title: 'WebRTC',
      keepAlive: true,
      requireAuth: true
    },
    component: () => import('@/views/test/test-webrtc-stream.vue')
  },
  {
    path: '/webrtc/pc',
    name: 'WebRTC',
    meta: {
      title: 'WebRTC',
      keepAlive: true,
      requireAuth: true
    },
    component: () => import('@/views/test/test-webrtc-peerconnection.vue')
  }
]

const historyMode = process.env.NODE_ENV === "production" ? createWebHashHistory() : createWebHistory();
const router = createRouter({
  history: historyMode,
  routes
});
export default router;